<template>
  <div class="app-container">
    <div class="card back">
      <el-button icon="el-icon-arrow-left" @click="back">返回</el-button>
    </div>

    <el-tabs type="border-card" v-model="activeName" v-if="!question.id">
      <el-tab-pane label="单题录入" name="singleEntry" />
      <el-tab-pane label="EXCEL录入" name="excelEntry" />
    </el-tabs>
    <div class="card main">
      <component :is="activeName" v-bind="$attrs"></component>
    </div>
  </div>
</template>

<script>
import singleEntry from "./singleEntry";
import excelEntry from "./excelEntry";

export default {
  inheritAttrs: false,
  components: { singleEntry, excelEntry },
  props: {
    question: {
      type: Object,
      default: () => ({}),
    },
  },
  provide() {
    return {
      question: this.question,
    };
  },
  data() {
    return {
      activeName: "singleEntry",
    };
  },
  methods: {
    back() {
      this.$emit("change", { componentName: "questionList" });
    },
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  min-height: 100%;
  background-color: #f4f5fc;
  .card {
    border: 1px solid #dcdfe6;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
    background-color: #fff;
  }
  .back {
    margin-bottom: 10px;
    padding: 12px 20px;
  }
  .main {
    padding: 20px;
  }
}
.el-tabs + .main {
  border-top: 0;
}

::v-deep {
  .el-tabs--border-card > .el-tabs__header {
    border-bottom: 0;
  }
  .el-tabs__content {
    padding: 0;
  }
  .el-tabs__item {
    font-size: 16px;
  }
}
</style>
